from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import sys
import logging

logging.basicConfig(level=logging.INFO, stream=sys.stdout)

Bucket = 'sanhangbei-1257646261'
secret_id = "AKIDYw5xYswkHXYHjuoSpvkIZZIkvoRnreAP"
secret_key = "1lDOJxKPDn67rLYU8WdT2JK4YppZ2EAp"
region = 'ap-chengdu'
token = None
scheme = 'https'

config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token, Scheme=scheme)
client = CosS3Client(config)


def delete(url):
    u = url.split('/')
    d = u[-2] + '/'
    f = u[-1]
    response = client.delete_object(
        Bucket=Bucket,
        Key=d + f,
    )
    print(response)
    response = client.delete_object(
        Bucket=Bucket,
        Key=d,
    )
    print(response)
